<?php

use kartik\datecontrol\Module;

$params = require(__DIR__ . '/params.php');

$config = [
    'defaultRoute' => 'index/index',
    'id' => 'basic',
    'name'=>'工程管理专业教学资源数据库',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log'],
    'language' => 'zh-CN',
    'modules' => [

        
        'gridview' => [
            'class' => '\kartik\grid\Module',
        // other module settings
        ],
        'api' => [
            'class' => 'app\api\Module'
        ],
        'user' => [
            'class' => 'dektrium\user\Module',
            'enableUnconfirmedLogin' => true,
            'confirmWithin' => 21600,
            'cost' => 12,
            'admins' => ['admin', 'badmin', 'lcw'],
        ],
        'rbac' => [
            'class' => 'dektrium\rbac\Module',
        ],
        'datecontrol' => [
            'class' => 'kartik\datecontrol\Module',
            // 需要显示的格式
            'displaySettings' => [
                //设置每种类型显示的格式
                Module::FORMAT_DATE => 'yyyy-MM-dd',
                Module::FORMAT_TIME => 'HH:mm:ss A',
                Module::FORMAT_DATETIME => 'yyyy-MM-dd HH:mm:ss A',
            ],
            //需要保存的格式 （'date' 等同于 Module::FORMAT_DATE，其余类似 ）
            'saveSettings' => [
                //设置每种类型显示的格式
                'date' => 'yyyy-MM-dd',
                'time' => 'HH:mm:ss A',
                'datetime' => 'yyyy-MM-dd HH:mm:ss A',
            ],
        ],
        'admin' => [
            'class' => 'mdm\admin\Module',
            'menus' => [
                'assignment' => [
                    'label' => '账号列表', // change label
//                    'url'=>array('/user/admin/index'),
                ],
                //隐藏规则、权限、路由菜单
                'rule' => null, // disable menu
                'permission' => null,
                'route'=>null,
            ],
            'layout' => 'top-menu',
//            'mainLayout' => '@app/views/layouts/main_1.php',
        ],
    ],
    'components' => [
        'request' => [
            'enableCsrfValidation' => false,
            // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
            'cookieValidationKey' => '!@#$%&*%￥@%￥#@！',
        ],
        'cache' => [
            'class' => 'yii\caching\FileCache',
        ],
//        'user' => [
//            'identityClass' => 'app\models\User',
//            'enableAutoLogin' => true,
//        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
        'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            'useFileTransport' => false, //这句一定有，false发送邮件，true只是生成邮件在runtime文件夹下，不发邮件
            'transport' => [
                'class' => 'Swift_SmtpTransport',
                'host' => 'smtp.163.com', //使用163邮件服务器
                'username' => 'zfatgxu@163.com',
                'password' => 'zbustrainf', //此处隐去密码  
                'port' => '465', //端口一般都是465
                'encryption' => 'ssl', //协议一般都是ssl安全协议
            ],
            'messageConfig' => [
                'charset' => 'UTF-8',
                'from' => ['zfatgxu@163.com' => 'admin']
            ],
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['trace', 'info'],
                    'categories' => ['weixin'],
                    'logFile' => '@app/runtime/logs/weixin.log',
                ],
            ],
        ],
        //yii2-admin 配置
//        'as access' => [
//            'class' => 'mdm\admin\components\AccessControl',
//            'allowActions' => [
//                'site/*',
//                'site/login',
//                'site/index',
//                'admin/*',
//                'index/*',
//            // The actions listed here will be allowed to everyone including guests.
//            // So, 'admin/*' should not appear here in the production, of course.
//            // But in the earlier stages of your development, you may probably want to
//            // add a lot of actions here until you finally completed setting up rbac,
//            // otherwise you may not even take a first step.
//            ]
//        ],
        'db' => require(__DIR__ . '/db.php'),
    ],
    'params' => $params,
];

if (YII_ENV_DEV) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = [
        'class' => 'yii\debug\Module',
    ];

    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = [
        'class' => 'yii\gii\Module',
    ];
}

return $config;
